package com.zmzncs.lmtc.module.promotion.pojo.reserve_rule;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zmzncs.lmtc.common.util.ExceptionUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author 高博文
 * @since 2020-08-12
 */
@Data
public class ReserveRuleAddForm implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "规则名称", required = true)
    @NotBlank
    @Size(max = 20)
    private String ruleName;

    @ApiModelProperty(value = "车场利润率", required = true)
    @NotNull
    @Max(value = 100)
    private Integer parkProfitRate;
//
//    @ApiModelProperty(value = "是否所有停车场（1：是，0否）", required = true)
//    @NotNull
//    private Integer ifAllParks;

//    @ApiModelProperty(value = "停车场id", required = true)
//    private List<Long> parkIds;
    @ApiModelProperty(value = "停车场id", required = true)
    private Long parkId;

    @ApiModelProperty(value = "时段费用", required = true)
    private List<TimeSlot> timeSlotList;

    @Data
    public static class TimeSlot{

        @ApiModelProperty(value = "时段开始时间(时分秒)", required = true)
        private String reserveBeginTime;

        @ApiModelProperty(value = "时段结束时间(时分秒)",required = true)
        private String reserveEndTime;

        @ApiModelProperty(value = "预约金额", required = true)
        private BigDecimal amount;
    }


    public void validate(){
        //  校验支付金额
        if(parkId == null){
            ExceptionUtil.paramException("预约时段费用必须有一个");
        }
    }




}
